import os

import pytest
import requests

from dotenv import load_dotenv
load_dotenv()

# 自动获取token
@pytest.fixture(scope='function')
def login_token():
    url="http://172.17.8.100/small/user/v1/login"
    body={
        "phone":os.system("LOGIN_NAME"),
        "pwd":os.system("LOGIN_PWD")
    }
    res=requests.post(url=url,json=body)
    r=res.json()
    # 获取userid,sessionid
    yield r['result']['userId'],r['result']['sessionId']
    # 注销
    del r['result']['userId'],r['result']['sessionId']